package com.ls.markt.controller;

import com.ls.markt.model.admin.Resources;
import com.ls.markt.service.admin.ResourcesServirce;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ls
 * @descript 主页控制器
 */
@RestController
public class MainController {

    @Resource
    ResourcesServirce resourcesServirce;

    @GetMapping("/")
    public ModelAndView root(Model model){
        List<Resources> resources = resourcesServirce.findAll();
        model.addAttribute("resources",resources);
        return new ModelAndView("index","resourcesModel",model);
    }

    @GetMapping("/welcome")
    public ModelAndView welcome(){
        return new ModelAndView("welcome");
    }

    @GetMapping("/importExcel")
    public ModelAndView importExcel(String type, Model model){
        model.addAttribute("type",type);
        return new ModelAndView("admin/excel/importExcel","typeModel",model);
    }
}
